﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using DXApplicationTangche.DTO;
using DXApplicationTangche.DTO.尖山;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.款式异常;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.订单一览新.辅料.service;
using DXApplicationTangche.UC.货号管理.service;
using DXApplicationTangche.UC.门店下单.UC;
using DXApplicationTangche.UC.门店下单.下单;
using DXApplicationTangche.原型;
using mendian;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.门店下单.DTO
{
    public class Dto定制下单
    {
        public String formId { get; set; }    // 样品下单的formId
        public String refOrderId { get; set; }//返单号Id
        public String refOrderNo { get; set; }//返单号No
        public String Style_Id { get; set; }    //  款式id
        public String SYTLE_FABRIC_ID { get; set; } //  面料id
        public String materialCode { get; set; } //面料号
        public String materialNameCn { get; set; } //面料名
        public String STYLE_CATEGORY_CD { get; set; }//款式类别
        public String STYLE_FIT_CD { get; set; } //版型
        public String STYLE_SIZE_GROUP_CD { get; set; }//尺码组
        public String STYLE_SIZE_CD { get; set; }//尺码
        public int ORDER_NUMBER { get; set; }   //  订单数量
        public String STYLE_DRESS_CATEGORY { get; set; }
        public String STYLE_DESIGN_TYPE { get; set; }
        public String REMARKS { get; set; }//备注
        public String STYLE_MAKE_TYPE { get; set; }//制作工艺
        public String STYLE_NAME_CN { get; set; }//款式名称  样衣用
        public List<备注图片> 备注图片s { get; set; } = new List<备注图片>();//备注图片
        public List<DTODesignPoints> Dto设计点s { get => dto设计点s; set => dto设计点s = value; }
        public DtoSize Dto尺寸 { get => dto尺寸; }

        private List<DTODesignPoints> dto设计点s = new List<DTODesignPoints>();   //  设计点
        private DtoSize dto尺寸;  //  尺寸

        public String sessionId { get; set; }
        public List<StyleAccessoryDTO> styleAccessoryDTOs { get; set; } = new List<StyleAccessoryDTO>();//新的辅料
        public Dto定制下单 build辅料By下单(标识StyleAccessoryDTO 标识StyleAccessoryDTO) {
            this.styleAccessoryDTOs = 标识StyleAccessoryDTO.styleAccessoryDTOs;
            return this;
        }
        public Dto定制下单 build设计点ByOrderCommit(List<DTODesignPoints设计点> dtoDesignPoints)
        {
            this.dto设计点s.Clear();
            foreach (DTODesignPoints设计点 dTODesignPoints in dtoDesignPoints)
            {
                this.dto设计点s.Add(new DTODesignPoints(dTODesignPoints));
            }
            return this;
        }
        public Dto定制下单 build设计点(String ITEM_CD, String ITEM_VALUE, String OPTION_VALUE, String ENABLE_FLAG, String DELETE_FLAG, String Name, String Style, Image pic)
        {
            this.dto设计点s.Add(new DTODesignPoints(ITEM_CD, ITEM_VALUE, OPTION_VALUE, ENABLE_FLAG, DELETE_FLAG, Name, Style, pic));
            return this;
        }
        public Dto定制下单 build备注图片(List<备注图片> pics)
        {
            this.备注图片s = pics;
            return this;
        }
        /// <summary>
        /// 三张空图
        /// </summary>
        /// <returns></returns>
        public Dto定制下单 build三张空备注图片()
        {
            this.备注图片s.Add(new 备注图片("1", null, "", ""));
            this.备注图片s.Add(new 备注图片("2", null, "", ""));
            this.备注图片s.Add(new 备注图片("3", null, "", ""));
            return this;
        }
        /// <summary>
        /// 删除空设计点
        /// </summary>
        /// <returns></returns>
        public Dto定制下单 Delete空设计点()
        {
            for (int i = this.Dto设计点s.Count - 1; i > 0; i--)
            {
                if (String.IsNullOrWhiteSpace(Dto设计点s[i].optionValue) && String.IsNullOrWhiteSpace(Dto设计点s[i].name))
                {
                    Dto设计点s.RemoveAt(i);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(Dto设计点s[i].optionValue + "=========" + Dto设计点s[i].name + "=======================");
                }
            }
            return this;
        }
        public Dto定制下单 build尺寸(String ITEM_CD, String ITEM_VALUE, String FIT_VALUE, String FM_VALUE, String IN_VALUE, String OUT_VALUE, String STATUS, String DELETE_FLAG, String CUSTOMER_COUNT_IDSTYLE_ID, String PHASE_CD, String VERSION, String CREATE_USER)
        {
            this.dto尺寸 = new DtoSize(ITEM_CD, ITEM_VALUE, FIT_VALUE, FM_VALUE, IN_VALUE, OUT_VALUE, STATUS, DELETE_FLAG, CUSTOMER_COUNT_IDSTYLE_ID, PHASE_CD, VERSION, CREATE_USER);
            return this;
        }
        public Dto定制下单 build选中款式(String Style_Id, String STYLE_CATEGORY_CD, String STYLE_FIT_CD, String STYLE_SIZE_GROUP_CD, String SYTLE_FABRIC_ID, String STYLE_MAKE_TYPE)
        {
            this.STYLE_MAKE_TYPE = STYLE_MAKE_TYPE;
            this.Style_Id = Style_Id;
            //this.STYLE_CATEGORY_CD = STYLE_CATEGORY_CD;
            this.STYLE_FIT_CD = STYLE_FIT_CD;
            this.STYLE_SIZE_GROUP_CD = STYLE_SIZE_GROUP_CD;
            //this.STYLE_SIZE_CD = this.tileView1.GetRowCellValue(e.Item.RowHandle, "STYLE_SIZE_CD").ToString();
            //this.SYTLE_FABRIC_ID = SYTLE_FABRIC_ID;
            return this;
        }
        //public Dto定制下单 build款式卡片(款式卡片DTO 款式卡片DTO) {
        //    this.Style_Id = 款式卡片DTO.kuanshiid;
        //    this.STYLE_CATEGORY_CD = 款式卡片DTO.sTYLE_CATEGORY_CD;
        //    this.STYLE_FIT_CD = 款式卡片DTO.sTYLE_FIT_CD;
        //    this.STYLE_SIZE_GROUP_CD = 款式卡片DTO.sTYLE_SIZE_GROUP_CD;
        //    this.STYLE_SIZE_CD = 款式卡片DTO.sTYLE_SIZE_CD;
        //    this.SYTLE_FABRIC_ID = 款式卡片DTO.mianliaoid;
        //    return this;
        //}
        public Dto定制下单 build面料(String SYTLE_FABRIC_ID)
        {
            this.SYTLE_FABRIC_ID = SYTLE_FABRIC_ID;
            return this;
        }
        public Dto定制下单 build数量(String ORDER_NUMBER)
        {
            try
            {
                this.ORDER_NUMBER = Convert.ToInt32(ORDER_NUMBER);
            }
            catch (Exception)
            {
            }
            return this;
        }
        public void verify订单()
        {
            this.verify样品();
            //if (String.IsNullOrEmpty(this.STYLE_SIZE_GROUP_CD))
            //{
            //    throw new Exception("尺码为空");
            //}
            //if (this.Dto设计点s.Count == 0) {
            //    throw new Exception("设计点为空");
            //}
            if (this.Dto尺寸 == null)
            {
                throw new Exception("尺寸为空");
            }
        }

        public void verify样品()
        {
            if (String.IsNullOrEmpty(this.Style_Id))
            {
                throw new Exception("款式id为空");
            }
            //if (String.IsNullOrEmpty(this.SYTLE_FABRIC_ID))
            //{
            //    throw new Exception("面料id为空");
            //}
            //if (String.IsNullOrEmpty(this.STYLE_CATEGORY_CD))
            //{
            //    throw new Exception("服装种类为空");
            //}
            //if (String.IsNullOrEmpty(this.STYLE_FIT_CD))
            //{
            //    throw new Exception("版型为空");
            //}
            if (this.ORDER_NUMBER <= 0)
            {
                throw new Exception("订单数量必须大于0");
            }
        }
    }

    /// <summary>
    /// 设计点
    /// </summary>
    public class DTODesignPoints
    {
        public DTODesignPoints(VO刺绣 vO刺绣)
        {
            this.itemCd = vO刺绣.itemCd;
            this.itemValue = vO刺绣.itemValue;
            this.itemTypeNameCn = vO刺绣.itemTypeNameCn;
            this.optionValue = vO刺绣.optionValue;
            this.name = vO刺绣.name;
        }
        public DTODesignPoints(DataRow dr, int i)
        {
            if (dr["ITEM_CD"].ToString() == "4SCON")
            {
                this.itemCd = dr["ITEM_VALUE"].ToString();
                this.itemValue = dr["DEFAULT_VALUE"].ToString();
                this.itemTypeNameCn = dr["ITEM_NAME_CN"].ToString();
                //this.OPTION_VALUE = dr["DEFAULT_VALUE"].ToString();
                this.name = dr["DEFAULT_NAME_CN"].ToString();
                this.enableFlag = "1";
                this.deleteFlag = "0";
            }
            else
            {
                this.itemCd = dr["ITEM_CD"].ToString();
                this.itemValue = dr["ITEM_VALUE"].ToString();
                this.itemTypeNameCn = dr["ITEM_NAME_CN"].ToString();
                this.optionValue = dr["DEFAULT_VALUE"].ToString();
                this.defaultValue = dr["DEFAULT_VALUE"].ToString();
                this.name = dr["DEFAULT_NAME_CN"].ToString();
                this.enableFlag = "1";
                this.deleteFlag = "0";
            }
        }


        public DTODesignPoints(string iTEM_CD, string iTEM_VALUE, string oPTION_VALUE, string eNABLE_FLAG, string dELETE_FLAG, String Name, String Style, Image pic)
        {
            this.itemCd = iTEM_CD;
            this.itemValue = iTEM_VALUE;
            this.optionValue = oPTION_VALUE;
            this.enableFlag = eNABLE_FLAG;
            this.deleteFlag = dELETE_FLAG;
            this.picture = pic == null ? FunctionHelper.getSSHIRT() : pic;



            this.name = Name;
            this.styleId = Style;
        }
        public DTODesignPoints(DataRow dr)
        {
            if (String.IsNullOrEmpty(dr["ITEM_NAME_CN"].ToString()))
            {
                this.itemValue = dr["ITEM_VALUE"].ToString();
                this.itemCd = dr["ITEM_CD"].ToString();
                this.optionValue = dr["OPTION_VALUE"].ToString();
                this.name = dr["ITEM_NAME_CN"].ToString();
                this.itemTypeNameCn = dr["ITEM_TYPE_NAME_CN"].ToString();
                this.styleId = dr["SYS_STYLE_ID"].ToString();
            }
            else
            {
                this.itemTypeNameCn = dr["ITEM_TYPE_NAME_CN"].ToString();
                this.name = dr["ITEM_NAME_CN"].ToString();
                this.itemCd = dr["ITEM_CD"].ToString();
                this.itemValue = dr["ITEM_VALUE"].ToString();
                this.optionValue = dr["OPTION_VALUE"].ToString();
                this.styleId = dr["SYS_STYLE_ID"].ToString();
            }
            try
            {
                this.picture = Image.FromFile(@"pic\" + dr["UPLOAD_FILE"].ToString());
            }
            catch (Exception) { }

            this.picture = this.picture == null ? FunctionHelper.getSSHIRT() : this.picture;
        }

        //  设计点种类
        public String itemTypeNameCn { get; set; }
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public String optionValue { get; set; }
        public String enableFlag { get; set; }
        public String deleteFlag { get; set; }
        public String defaultValue { get; set; }

        public Image picture { get; set; }
        //  设计点名称
        public String name { get; set; }
        public String styleId { get; set; }//款式id
        /// <summary>
        /// 坚山团体用
        /// </summary>
        /// <param name="itemCd"></param>
        /// <param name="itemValue"></param>
        /// <param name="itemTypeNameCn"></param>
        /// <param name="optionValue"></param>
        /// <param name="name"></param>
        public DTODesignPoints (String itemCd, String itemValue,String itemTypeNameCn, String optionValue,String name)
        {
            this.itemCd = itemCd;
            this.itemValue = itemValue;
            this.itemTypeNameCn = itemTypeNameCn;
            this.optionValue = optionValue;
            this.name = name;
            this.enableFlag = "1";
            this.deleteFlag = "0";
        }
        public DTODesignPoints build设计点(String itemName, String itemValue, Image pic)
        {
            this.name = itemName;
            this.optionValue = itemValue;
            this.picture = pic;
            return this;
        }
        public DTODesignPoints()
        {
            this.itemTypeNameCn = "";
            this.itemCd = "";
            this.itemValue = "";
            this.optionValue = "";
            this.enableFlag = "";
            this.deleteFlag = "";
            this.defaultValue = "";
            this.picture = null;
            //  设计点名称
            this.name = "";
            this.styleId = "";
        }
        /// <summary>
        /// excel导入用
        /// </summary>
        /// <param name="item_cd"></param>
        /// <param name="item_value"></param>
        /// <param name="option_value"></param>
        /// <returns></returns>
        public DTODesignPoints buildFromExcel(String item_cd, String item_value, String option_value)
        {
            this.itemCd = item_cd;
            this.itemValue = item_value;
            this.optionValue = option_value;
            return this;
        }
        public DTODesignPoints buildFromExcel新(String item_cd, String item_value, String option_value,String itemTypeNameCn,String name)
        {
            this.itemCd = item_cd;
            this.itemValue = item_value;
            this.optionValue = option_value;
            this.itemTypeNameCn = itemTypeNameCn;
            this.name = name;
            return this;
        }

        public DTODesignPoints(DTODesignPoints设计点 dTODesignPoints)
        {
            this.itemTypeNameCn = dTODesignPoints.itemTypeNameCn;
            this.itemCd = dTODesignPoints.itemCd;
            this.itemValue = dTODesignPoints.itemValue;
            this.optionValue = dTODesignPoints.optionValue;
            this.enableFlag = dTODesignPoints.enableFlag;
            this.deleteFlag = dTODesignPoints.deleteFlag;
            this.defaultValue = dTODesignPoints.defaultValue;
            //  设计点名称
            this.name = dTODesignPoints.name;
            this.styleId = dTODesignPoints.styleId;//款式id
            this.picture= FunctionHelper.getSSHIRT();
        }
    }

    public class DtoSize //dto尺寸
    {
        public DtoSize()
        {

        }
        public DtoSize(string iTEM_CD, string iTEM_VALUE, string fIT_VALUE, string fM_VALUE, string iN_VALUE, string oUT_VALUE, string sTATUS, string dELETE_FLAG, string cUSTOMER_COUNT_ID, string pHASE_CD, string vERSION, string cREATE_USER)
        {
            this.itemCd = iTEM_CD;
            this.itemValue = iTEM_VALUE;
            this.fitValue = fIT_VALUE;
            this.fmValue = fM_VALUE;
            this.inValue = iN_VALUE;
            this.outValue = oUT_VALUE;
            this.status = sTATUS;
            this.deleteFlag = dELETE_FLAG;
            this.customerCountId = cUSTOMER_COUNT_ID;
            this.phaseCd = pHASE_CD;
            this.version = vERSION;
            this.createUser = cREATE_USER;
        }

        /// <summary>
        /// 美国坚山Excel尺寸
        /// </summary>
        /// <param name="dTOMeasurements"></param>
        public DtoSize(DTOMeasurements dTOMeasurements, String FIT_CD)
        {
            String 左长袖总长 = "0";
            String 右长袖总长 = "0";
            String 左长袖长 = "0";
            String 右长袖长 = "0";
            String 短袖总长 = "0";
            String 短袖长 = "0";
            String 二分之一肩宽 = "0";
            DTO坚山美国订单导入 dTO = new DTO坚山美国订单导入().build尺寸名称对应().build英文找CV();
            #region 新尺寸方法
            int index = 1;
            foreach (DTOUS坚山ExcelSize dTOUS in dTOMeasurements.dTOUS坚山ExcelSize)
            {
                String ICD = dTO.Dic英文找CV[dTOUS.sizeName].ITEM_CD;
                String IVL = dTO.Dic英文找CV[dTOUS.sizeName].ITEM_VALUE;
                String INC = dTO.Dic英文找CV[dTOUS.sizeName].ITEM_NAME_CN;

                this.itemCd = this.itemCd + ICD + ",";
                this.itemValue = this.itemValue + IVL + ",";
                this.fmValue = this.itemValue + IVL + ",";

                String 试样衣尺寸 = dTOUS.masterSize;
                String 加减值 = dTOUS.adjustment;
                String 成衣尺寸 = dTOUS.garmentMeasurement;
                试样衣尺寸 = String.IsNullOrWhiteSpace(试样衣尺寸) ? "0" : 试样衣尺寸;
                加减值 = String.IsNullOrWhiteSpace(加减值) || 加减值.Contains("N") ? "0" : 加减值;
                成衣尺寸 = String.IsNullOrWhiteSpace(成衣尺寸) ? "0" : 成衣尺寸;
                if (dTOUS.sizeName.Contains("Shoulder") || dTOUS.sizeName.Contains("Chest") || dTOUS.sizeName.Contains("Stomach") || dTOUS.sizeName.Contains("Hips"))
                {
                    试样衣尺寸 = (Convert.ToDouble(试样衣尺寸) / 2).ToString();
                    加减值 = (Convert.ToDouble(加减值) / 2).ToString();
                    成衣尺寸 = (Convert.ToDouble(成衣尺寸) / 2).ToString();
                }
                if (dTOUS.sizeName.Contains("Length L"))
                {
                    左长袖总长 = 成衣尺寸;
                }
                else if (dTOUS.sizeName.Contains("Length R"))
                {
                    右长袖总长 = 成衣尺寸;
                }
                else if (dTOUS.sizeName.Contains("Sleeve Length"))
                {
                    短袖总长 = 成衣尺寸;
                }
                else if (dTOUS.sizeName.Contains("Shoulder"))
                {
                    二分之一肩宽 = 成衣尺寸;
                }
                this.fitValue = this.fitValue + 成衣尺寸 + ",";

                //if (!dTOUS.sizeName.Contains("Length L") &&
                //    !dTOUS.sizeName.Contains("Length R") &&
                //    !dTOUS.sizeName.Contains("Sleeve Length") &&
                //    !dTOUS.sizeName.Contains("Shoulder"))
                //{
                    if (Convert.ToDouble(加减值) > 0)
                    {
                        this.inValue = this.inValue + 加减值 + ",";
                        this.outValue = this.outValue + "NaN" + ",";
                        //尺寸
                        this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(成衣尺寸),
                        Convert.ToDouble(加减值),
                        ICD,
                        Convert.ToDouble(试样衣尺寸),
                        INC,
                        IVL,
                        0,
                        0,
                        0,
                        ""));
                        this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(ICD, IVL, INC, Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, Convert.ToDouble(加减值), 0));
                    }
                    else if (Convert.ToDouble(加减值) < 0)
                    {
                        this.inValue = this.inValue + "NaN" + ",";
                        this.outValue = this.outValue + (-Convert.ToDouble(加减值)).ToString() + ",";
                        //尺寸
                        this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(成衣尺寸),
                        0,
                        ICD,
                        Convert.ToDouble(试样衣尺寸),
                        INC,
                        IVL,
                        0,
                        0,
                        -Convert.ToDouble(加减值),
                        ""));
                        this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(ICD, IVL, INC, Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, -Convert.ToDouble(加减值)));
                    }
                    else if (Convert.ToDouble(加减值) == 0)
                    {
                        this.inValue = this.inValue + "NaN" + ",";
                        this.outValue = this.outValue + "NaN" + ",";
                        //尺寸
                        this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(成衣尺寸),
                        0,
                        ICD,
                        Convert.ToDouble(Convert.ToDouble(试样衣尺寸)),
                        INC,
                        IVL,
                        0,
                        0,
                        0,
                        ""));
                        this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(ICD, IVL, INC, Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
                    //}
                }
                index++;
            }
            #region 各种袖长
            左长袖长 = (Convert.ToDouble(左长袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            右长袖长 = (Convert.ToDouble(右长袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            短袖长 = (Convert.ToDouble(短袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            index++;
            //尺寸
            this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(左长袖长),
                        0,
                        "SHIRT_LENGT002",
                        0,
                        "左长袖袖长",
                        "POSTU_ITEM_07",
                        0,
                        0,
                        0,
                        ""));
            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "POSTU_ITEM_07", "左长袖袖长", Convert.ToDouble(左长袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            this.itemValue = this.itemValue + "POSTU_ITEM_07" + ",";
            this.fmValue = this.itemValue + "POSTU_ITEM_07" + ",";
            this.fitValue = this.fitValue + 左长袖长 + ",";
            this.inValue = this.inValue + "NaN" + ",";
            this.outValue = this.outValue + "NaN" + ",";
            index++;
            //尺寸
            this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(右长袖长),
                        0,
                        "SHIRT_LENGT002",
                        0,
                        "右长袖袖长",
                        "POSTU_ITEM_09",
                        0,
                        0,
                        0,
                        ""));
            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "POSTU_ITEM_09", "右长袖袖长", Convert.ToDouble(右长袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            this.itemValue = this.itemValue + "POSTU_ITEM_09" + ",";
            this.fmValue = this.itemValue + "POSTU_ITEM_09" + ",";
            this.fitValue = this.fitValue + 右长袖长 + ",";
            this.inValue = this.inValue + "NaN" + ",";
            this.outValue = this.outValue + "NaN" + ",";
            index++;
            //尺寸
            this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(短袖长),
                        0,
                        "SHIRT_LENGT002",
                        0,
                        "左短袖袖长",
                        "LENGT_ITEM_06",
                        0,
                        0,
                        0,
                        ""));
            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "LENGT_ITEM_06", "左短袖袖长", Convert.ToDouble(短袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            this.itemValue = this.itemValue + "LENGT_ITEM_06" + ",";
            this.fmValue = this.itemValue + "LENGT_ITEM_06" + ",";
            this.fitValue = this.fitValue + 短袖长 + ",";
            this.inValue = this.inValue + "NaN" + ",";
            this.outValue = this.outValue + "NaN" + ",";
            index++;
            //尺寸
            this.measureItemDTOS.Add(new MeasureItemDTO(
                        index.ToString(),
                        "",
                        index,
                        false,
                        true,
                        false,
                        0,
                        "",
                        Convert.ToDouble(短袖长),
                        0,
                        "SHIRT_LENGT002",
                        0,
                        "右短袖袖长",
                        "LENGT_ITEM_05",
                        0,
                        0,
                        0,
                        ""));
            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "LENGT_ITEM_05", "右短袖袖长", Convert.ToDouble(短袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            this.itemValue = this.itemValue + "LENGT_ITEM_05" + ",";
            this.fmValue = this.itemValue + "LENGT_ITEM_05" + ",";
            this.fitValue = this.fitValue + 短袖长 + ",";
            this.inValue = this.inValue + "NaN" + ",";
            this.outValue = this.outValue + "NaN" + ",";
            #endregion
            #endregion

            #region 老代码
            //DataTable dt尺寸 = SQLmtm.GetDataTable("SELECT\n" +
            //                "	* \n" +
            //                "FROM\n" +
            //                "	a_size_fit_p \n" +
            //                "WHERE\n" +
            //                "	FIT_CD = '" + FIT_CD + "' \n" +
            //                "	AND SIZE_CD = 'EGS_GROUP_SIZE-" + dTOMeasurements.Size + "';");

            //foreach (DataRow dr in dt尺寸.Rows)
            //{
            //    this.itemCd = this.itemCd + dr["ITEM_CD"].ToString() + ",";
            //    this.itemValue = this.itemValue + dr["ITEM_VALUE"].ToString() + ",";
            //    this.fmValue = this.itemValue + dr["ITEM_VALUE"].ToString() + ",";
            //    String 成衣尺寸 = "";
            //    String SizeName;
            //    try
            //    {
            //        //Size属性 = new 尺寸属性(dr["ITEM_CD"].ToString(), dr["ITEM_VALUE"].ToString());
            //        String str = dr["ITEM_VALUE"].ToString();
            //        SizeName = dTO.Dic尺寸名称对应[str];
            //        成衣尺寸 = dTOMeasurements.map[SizeName];
            //        成衣尺寸 = 成衣尺寸 == "" ? "0" : 成衣尺寸;
            //        if (SizeName.Contains("Shoulder") || SizeName.Contains("Chest") || SizeName.Contains("Stomach") || SizeName.Contains("Hips"))
            //        {
            //            成衣尺寸 = (Convert.ToDouble(成衣尺寸) / 2).ToString();
            //        }
            //        if (SizeName.Contains("Length L"))
            //        {
            //            左长袖总长 = 成衣尺寸;
            //        }
            //        else if (SizeName.Contains("Length R"))
            //        {
            //            右长袖总长 = 成衣尺寸;
            //        }
            //        else if (SizeName.Contains("Sleeve Length"))
            //        {
            //            短袖总长 = 成衣尺寸;
            //        }
            //        else if (SizeName.Contains("Shoulder"))
            //        {
            //            二分之一肩宽 = 成衣尺寸;
            //        }
            //    }
            //    catch
            //    {
            //        成衣尺寸 = "0";
            //    }
            //    成衣尺寸 = 成衣尺寸 == "" ? "0" : 成衣尺寸;
            //    this.fitValue = this.fitValue + 成衣尺寸 + ",";
            //    Double 差值 = Convert.ToDouble(成衣尺寸) - Convert.ToDouble(dr["ITEM_FIT_VALUE"].ToString());
            //    if (dr["ITEM_VALUE"].ToString() != "POSTU_ITEM_07" &&
            //        dr["ITEM_VALUE"].ToString() != "POSTU_ITEM_09" &&
            //        dr["ITEM_VALUE"].ToString() != "LENGT_ITEM_06" &&
            //        dr["ITEM_VALUE"].ToString() != "LENGT_ITEM_05")
            //    {
            //        if (差值 > 0)
            //        {
            //            this.inValue = this.inValue + 差值.ToString() + ",";
            //            this.outValue = this.outValue + "NaN" + ",";
            //            //尺寸
            //            this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(成衣尺寸),
            //            差值,
            //            dr["ITEM_CD"].ToString(),
            //            Convert.ToDouble(dr["ITEM_FIT_VALUE"].ToString()),
            //            dr["ITEM_NAME_CN"].ToString(),
            //            dr["ITEM_VALUE"].ToString(),
            //            0,
            //            0,
            //            0,
            //            ""));
            //            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(dr["ITEM_CD"].ToString(), dr["ITEM_VALUE"].ToString(), dr["ITEM_NAME_CN"].ToString(), Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 差值, 0));
            //        }
            //        else if (差值 < 0)
            //        {
            //            this.inValue = this.inValue + "NaN" + ",";
            //            this.outValue = this.outValue + (-差值).ToString() + ",";
            //            //尺寸
            //            this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(成衣尺寸),
            //            0,
            //            dr["ITEM_CD"].ToString(),
            //            Convert.ToDouble(dr["ITEM_FIT_VALUE"].ToString()),
            //            dr["ITEM_NAME_CN"].ToString(),
            //            dr["ITEM_VALUE"].ToString(),
            //            0,
            //            0,
            //            -差值,
            //            ""));
            //            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(dr["ITEM_CD"].ToString(), dr["ITEM_VALUE"].ToString(), dr["ITEM_NAME_CN"].ToString(), Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, -差值));
            //        }
            //        else if (差值 == 0)
            //        {
            //            this.inValue = this.inValue + "NaN" + ",";
            //            this.outValue = this.outValue + "NaN" + ",";
            //            //尺寸
            //            this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(成衣尺寸),
            //            0,
            //            dr["ITEM_CD"].ToString(),
            //            Convert.ToDouble(dr["ITEM_FIT_VALUE"].ToString()),
            //            dr["ITEM_NAME_CN"].ToString(),
            //            dr["ITEM_VALUE"].ToString(),
            //            0,
            //            0,
            //            0,
            //            ""));
            //            this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO(dr["ITEM_CD"].ToString(), dr["ITEM_VALUE"].ToString(), dr["ITEM_NAME_CN"].ToString(), Convert.ToDouble(成衣尺寸), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            //        }
            //    }
            //    index++;
            //}
            //#region 各种袖长添加
            //左长袖长 = (Convert.ToDouble(左长袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            //右长袖长 = (Convert.ToDouble(右长袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            //短袖长 = (Convert.ToDouble(短袖总长) - Convert.ToDouble(二分之一肩宽)).ToString();
            //index++;
            ////尺寸
            //this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(左长袖长),
            //            0,
            //            "SHIRT_LENGT002",
            //            0,
            //            "左长袖袖长",
            //            "POSTU_ITEM_07",
            //            0,
            //            0,
            //            0,
            //            ""));
            //this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "POSTU_ITEM_07", "左长袖袖长", Convert.ToDouble(左长袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            //this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            //this.itemValue = this.itemValue + "POSTU_ITEM_07" + ",";
            //this.fmValue = this.itemValue + "POSTU_ITEM_07" + ",";
            //this.fitValue = this.fitValue + 左长袖长 + ",";
            //this.inValue = this.inValue + "NaN" + ",";
            //this.outValue = this.outValue + "NaN" + ",";
            //index++;
            ////尺寸
            //this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(右长袖长),
            //            0,
            //            "SHIRT_LENGT002",
            //            0,
            //            "右长袖袖长",
            //            "POSTU_ITEM_09",
            //            0,
            //            0,
            //            0,
            //            ""));
            //this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "POSTU_ITEM_09", "右长袖袖长", Convert.ToDouble(右长袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            //this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            //this.itemValue = this.itemValue + "POSTU_ITEM_09" + ",";
            //this.fmValue = this.itemValue + "POSTU_ITEM_09" + ",";
            //this.fitValue = this.fitValue + 右长袖长 + ",";
            //this.inValue = this.inValue + "NaN" + ",";
            //this.outValue = this.outValue + "NaN" + ",";
            //index++;
            ////尺寸
            //this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(短袖长),
            //            0,
            //            "SHIRT_LENGT002",
            //            0,
            //            "左短袖袖长",
            //            "LENGT_ITEM_06",
            //            0,
            //            0,
            //            0,
            //            ""));
            //this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "LENGT_ITEM_06", "左短袖袖长", Convert.ToDouble(短袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            //this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            //this.itemValue = this.itemValue + "LENGT_ITEM_06" + ",";
            //this.fmValue = this.itemValue + "LENGT_ITEM_06" + ",";
            //this.fitValue = this.fitValue + 短袖长 + ",";
            //this.inValue = this.inValue + "NaN" + ",";
            //this.outValue = this.outValue + "NaN" + ",";
            //index++;
            ////尺寸
            //this.measureItemDTOS.Add(new MeasureItemDTO(
            //            index.ToString(),
            //            "",
            //            index,
            //            false,
            //            true,
            //            false,
            //            0,
            //            "",
            //            Convert.ToDouble(短袖长),
            //            0,
            //            "SHIRT_LENGT002",
            //            0,
            //            "右短袖袖长",
            //            "LENGT_ITEM_05",
            //            0,
            //            0,
            //            0,
            //            ""));
            //this.kashiyamaSizeFitDTOs.Add(new KashiyamaSizeFitDTO("SHIRT_LENGT002", "LENGT_ITEM_05", "右短袖袖长", Convert.ToDouble(短袖长), "", "EGS_GROUP_SIZE-" + dTOMeasurements.Size, 0, 0));
            //this.itemCd = this.itemCd + "SHIRT_LENGT002" + ",";
            //this.itemValue = this.itemValue + "LENGT_ITEM_05" + ",";
            //this.fmValue = this.itemValue + "LENGT_ITEM_05" + ",";
            //this.fitValue = this.fitValue + 短袖长 + ",";
            //this.inValue = this.inValue + "NaN" + ",";
            //this.outValue = this.outValue + "NaN" + ",";
            //#endregion
            #endregion



            this.phaseCd = "AUDIT_PHASE_CD-PHASE_CD_10";
            this.deleteFlag = "0";
            this.version = "1";
        }
        /// <summary>
        /// 从数据库取数据
        /// </summary>
        /// <param name="STYLE_ID"></param>
        /// <param name="iTEM_CD"></param>
        /// <param name="iTEM_VALUE"></param>
        /// <param name="fIT_VALUE"></param>
        /// <param name="fM_VALUE"></param>
        /// <param name="iN_VALUE"></param>
        /// <param name="oUT_VALUE"></param>
        /// <param name="sTATUS"></param>
        /// <param name="dELETE_FLAG"></param>
        /// <param name="cUSTOMER_COUNT_ID"></param>
        /// <param name="pHASE_CD"></param>
        /// <param name="vERSION"></param>
        /// <param name="cREATE_USER"></param>
        public DtoSize(DataRow dr)
        {
            this.styleId = dr["STYLE_ID"].ToString();
            this.itemCd = dr["ITEM_CD"].ToString();
            this.itemValue = dr["ITEM_VALUE"].ToString();
            this.fitValue = dr["FIT_VALUE"].ToString();
            this.fmValue = dr["FM_VALUE"].ToString();
            this.inValue = dr["IN_VALUE"].ToString();
            this.outValue = dr["OUT_VALUE"].ToString();
            this.deleteFlag = dr["DELETE_FLAG"].ToString();
            this.phaseCd = dr["PHASE_CD"].ToString();
            this.version = dr["VERSION"].ToString();
            this.createUser = dr["CREATE_USER"].ToString();
        }

        public void build尺寸呈现dto(List<尺寸呈现dto> 尺寸呈现dto, DataTable dataTable客户量体值, Dictionary<String, String> sizePairs)
        {
            Dictionary<String, Double> dic量体制kv = new Dictionary<string, Double>();
            foreach (DataRow dataRow in dataTable客户量体值.Rows)
            {
                try
                {
                    dic量体制kv.Add(dataRow["ITEM_VALUE"].ToString(), Convert.ToDouble(dataRow["FIT_VALUE"].ToString()));
                }
                catch { }

            }

            List<String> ITEM_CD = new List<string>(this.itemCd.Split(','));
            List<String> ITEM_VALUE = new List<string>(this.itemValue.Split(','));
            List<String> IN_VALUE = new List<string>(this.inValue.Split(','));
            List<String> OUT_VALUE = new List<string>(this.outValue.Split(','));

            for (int i = 0; i < 尺寸呈现dto.Count; i++)
            {
                for (int j = 0; j < ITEM_VALUE.Count; j++)
                {
                    if (尺寸呈现dto[i].ITEM_VALUE.Equals(ITEM_VALUE[j]))
                    {
                        尺寸呈现dto[i].IN_VALUE = Convert.ToDouble("NaN".Equals(IN_VALUE[j]) ? "0" : IN_VALUE[j]);
                        尺寸呈现dto[i].OUT_VALUE = Convert.ToDouble("NaN".Equals(OUT_VALUE[j]) ? "0" : OUT_VALUE[j]);
                        try
                        {
                            尺寸呈现dto[i].CUSTOMER_FIT_VALUE = dic量体制kv[
                                sizePairs[尺寸呈现dto[i].ITEM_VALUE]    //  成衣量体制和客户量体值转换
                            ];  //  TODO    修改量体值
                        }
                        catch { }
                        尺寸呈现dto[i].buildCUSTOMER_FIT_VALUE();

                        //尺寸呈现dto[i].ITEM_VALUE = ITEM_VALUE[j];
                        尺寸呈现dto[i].CountSize();
                        break;
                    }
                }
            }
        }

        public String styleId { get; set; }
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public String fitValue { get; set; }
        public String fmValue { get; set; }
        public String inValue { get; set; }
        public String outValue { get; set; }
        public String status { get; set; }
        public String deleteFlag { get; set; }
        public String customerCountId { get; set; }
        public String phaseCd { get; set; }
        public String version { get; set; }
        public String createUser { get; set; }

        public List<KashiyamaSizeFitDTO> kashiyamaSizeFitDTOs { get; set; } = new List<KashiyamaSizeFitDTO>();
        public List<MeasureItemDTO> measureItemDTOS { get; set; } = new List<MeasureItemDTO>();//尺寸
    }

    public class DTO款式备选
    {
        public String styleId { get; set; }
        public String code { get; set; }
        public String name { get; set; }

        public DTO款式备选(String ID, String Code, String Name)
        {
            this.styleId = ID;
            this.name = Name;
            this.code = Code;
        }
    }

    public class 款式维护记录
    {
        public String id { get; set; }
        public String styleCategoryId { get; set; }
        public String styleCategoryName { get; set; }   //  款式类别
        public String serials { get; set; } //  系列
        public String styleId { get; set; } //  款式ID
        public String styleCode { get; set; }   // 款式编码
        public Boolean fitImport { get; set; }  // 尺寸是否导入
        public Boolean styleImport { get; set; }    // 设计点是否导入
        public 款式维护记录()
        {
            this.id = "";
            this.styleCategoryId = "";
            this.styleCategoryName = "";
            this.serials = "";
            this.styleId = "";
            this.styleCode = "";
            this.fitImport = false;
            this.styleImport = false;
        }
    }

    public class 面料选择
    {
        public String materialNameCn { get; set; }
        public String materialCode { get; set; }
        public String materialComposition { get; set; }
        //public String materialId { get; set; }
        public Double fabricQuanlity { get; set; }//  库存数量
        public Double unitPrice { get; set; }//  库存加权平均价格

        public 面料选择()
        {

        }
    }

    public class KashiyamaSizeFitDTO
    {
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public String itemNameCn { get; set; }
        public double itemFitValue { get; set; }
        public String fitCd { get; set; }
        public String sizeCd { get; set; }
        public double inValue { get; set; }
        public double outValue { get; set; }
        public KashiyamaSizeFitDTO(string itemCd, string itemValue, string itemNameCn, double itemFitValue, string fitCd, string sizeCd, double inValue, double outValue)
        {
            this.itemCd = itemCd;
            this.itemValue = itemValue;
            this.itemNameCn = itemNameCn;
            this.itemFitValue = itemFitValue;
            this.fitCd = fitCd;
            this.sizeCd = sizeCd;
            this.inValue = inValue;
            this.outValue = outValue;
        }
    }
}
